# Copyright (c) 2025 Huawei Technologies Co., Ltd.
# openUBMC is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#         http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.

cmake_minimum_required(VERSION 3.16)
project(signer)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)

SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)


find_package(PkgConfig REQUIRED)
pkg_search_module(SSL REQUIRED libssl)
pkg_search_module(CRYPTO REQUIRED libcrypto)

ADD_EXECUTABLE(hpm_verify cms_ver.c)
target_link_directories(hpm_verify PUBLIC ${SSL_LIBRARY_DIRS} ${CRYPTO_LIBRARY_DIRS} ${CONAN_LIBS})
target_link_libraries(hpm_verify PUBLIC libssl.a libcrypto.a dl pthread ${CONAN_LIBS})
target_include_directories(hpm_verify PUBLIC ${SSL_INCLUDE_DIR} ${CRYPTO_INCLUDE_DIR})

ADD_EXECUTABLE(hpm_signer cms_sign.c)
target_link_directories(hpm_signer PUBLIC ${SSL_LIBRARY_DIRS} ${CRYPTO_LIBRARY_DIRS} ${CONAN_LIBS})
target_link_libraries(hpm_signer PUBLIC libssl.a libcrypto.a dl pthread ${CONAN_LIBS})
target_include_directories(hpm_signer PUBLIC ${SSL_INCLUDE_DIR} ${CRYPTO_INCLUDE_DIR})

INSTALL(TARGETS hpm_verify RUNTIME DESTINATION usr/local/bin)
INSTALL(TARGETS hpm_signer RUNTIME DESTINATION usr/local/bin)
